Subversion Repositories Applications.papyrus

Rev

Rev 1108 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1108 florian 1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
8
// | This library is free software; you can redistribute it and/or                                        |
9
// | modify it under the terms of the GNU Lesser General Public                                           |
10
// | License as published by the Free Software Foundation; either                                         |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
12
// |                                                                                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
16
// | Lesser General Public License for more details.                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
19
// | License along with this library; if not, write to the Free Software                                  |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
22
// CVS : $Id$
23
/**
24
* Formulaire
25
*
2150 mathias 26
* Classe générique pour créer des formulaires
1108 florian 27
*
28
*@package Formulaire
29
//Auteur original :
30
*@author        Florian SCHMITT <florian@ecole-et-nature.org>
31
//Autres auteurs :
32
*@copyright     Tela-Botanica 2000-2004
33
*@version       $Revision$ $Date$
34
// +------------------------------------------------------------------------------------------------------+
35
*/
36
 
37
// +------------------------------------------------------------------------------------------------------+
38
// |                                            ENTETE du PROGRAMME                                       |
39
// +------------------------------------------------------------------------------------------------------+
40
if (!function_exists('bugFixRequirePath')) {
41
   function bugFixRequirePath($newPath) {
42
       $stringPath = dirname(__FILE__);
43
       if (strstr($stringPath,":")) $stringExplode = "\\";
44
       else $stringExplode = "/";
45
       $paths = explode($stringExplode,$stringPath);
46
       $newPaths = explode("/",$newPath);
47
       if (count($newPaths) > 0) {
48
           for($i=0;$i<count($newPaths);$i++) {
49
               if ($newPaths[$i] == "..") array_pop($paths);
50
           }
51
           for($i=0;$i<count($newPaths);$i++) {
52
               if ($newPaths[$i] == "..") unset($newPaths[$i]);
53
           }
54
           reset($newPaths);
55
           $stringNewPath = implode($stringExplode,$paths).$stringExplode.implode($stringExplode,$newPaths);
56
           return $stringNewPath;
57
       }
58
   }
59
}
60
require_once bugFixRequirePath('../../../api/pear/HTML/QuickForm.php') ;
61
require_once bugFixRequirePath('../../../api/pear/HTML/QuickForm/html.php') ;
62
require_once bugFixRequirePath('../../../api/pear/HTML/QuickForm/textarea.php') ;
63
require_once 'formulaire.fonct.inc.php' ;
64
 
65
class HTML_formulaire extends HTML_Quickform {
66
    /**
67
     *  Constructeur
68
     *
69
     * @param string formName Le nom du formulaire
2150 mathias 70
     * @param string method Méthode post ou get
1108 florian 71
     * @param string action L'action du formulaire.
72
     * @param int target La cible.
73
     * @param Array attributes Les attributs HTML en plus.
74
     * @param bool trackSubmit ??
75
     * @return void
76
     * @access public
77
     */
78
    function HTML_formulaire( $formName, $action, $template_champs_formulaire, $method = "post", $target=NULL, $attributes=NULL, $trackSubmit=false ) {
79
		HTML_Quickform::HTML_Quickform($formName, $method, $action, $target, $attributes, $trackSubmit) ;
80
		$this->removeAttribute('name');
81
		$squelette =& $this->defaultRenderer();
82
		$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'{content}'."\n".'</form>'."\n");
83
		$squelette->setElementTemplate( '<p class="formulaire_element">'."\n".'<label>'."\n".
84
			'{label}'."\n".
85
			'<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->&nbsp;:'."\n".
86
			'</label>'."\n".
87
			'{element}'."\n".
88
			'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
89
			'</p>'."\n");
90
		$squelette->setRequiredNoteTemplate("\n".'<p class="symbole_obligatoire">*&nbsp;:&nbsp;{requiredNote}</p>'."\n");
91
		//Traduction de champs requis
92
		$this->setRequiredNote('champs obligatoire') ;
93
		$this->setJsWarnings('Erreur de saisie', 'Veuillez verifier vos informations saisies');
94
		$tableau=formulaire_valeurs_template_champs($template_champs_formulaire);
95
		for ($i=0; $i<count($tableau); $i++) {
96
			$tableau[$i]['type']($this, $tableau[$i]['nom_bdd'], $tableau[$i]['label'],
97
			$tableau[$i]['limite1'],
98
			$tableau[$i]['limite2'], $tableau[$i]['defaut'], $tableau[$i]['table_source'],
99
			$tableau[$i]['obligatoire']) ;
100
		}
101
	}
102
 
103
 
104
 /**
105
     *
106
     *
107
     * @return string
108
     * @access public
109
     */
110
    function toHTML( )
111
    {
112
        $res = HTML_QuickForm::toHTML() ;
113
        return $res ;
114
    } // end of member function toHTML
115
}
116
 
117
?>