Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
Class.SubForm.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5  * @package FDL
6 */
7 /**
8  * Generated Header (not documented yet)
9  *
10  * @author Anakeen 2000
11  * @version $Id: Class.SubForm.php,v 1.3 2006/06/20 16:18:07 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage CORE
15  */
16 /**
17  */
18 // ---------------------------------------------------------------------------
19 // $Id: Class.SubForm.php,v 1.3 2006/06/20 16:18:07 eric Exp $
20 // $Source: /home/cvsroot/anakeen/freedom/core/Class/Form/Class.SubForm.php,v $
21 // ---------------------------------------------------------------
22 // $Log: Class.SubForm.php,v $
23 // Revision 1.3 2006/06/20 16:18:07 eric
24 // new font size theme
25 //
26 // Revision 1.2 2003/08/18 15:46:42 eric
27 // phpdoc
28 //
29 // Revision 1.1 2002/01/08 12:41:34 eric
30 // first
31 //
32 // Revision 1.3 2000/10/26 12:52:13 yannick
33 // Bug : perte du mot de passe
34 //
35 // Revision 1.2 2000/10/23 14:21:27 marc
36 // Use of select in forms
37 //
38 // Revision 1.1 2000/10/19 16:34:45 yannick
39 // Pour Marc
40 //
41 //
42 $CLASS_SUBFORM_PHP = '$Id: Class.SubForm.php,v 1.3 2006/06/20 16:18:07 eric Exp $';
43 
44 class SubForm
45 {
46  // This class is used to produce HTML/JS code when you want to
47  // create a separate window which exchange values with its parent
48  // window (for instance an edit/update window or a query window)
49  var $mainjs = '
50 function submit_withpar(height,width,name,[id],url) {
51  subwindow(height,width,name,url+\'&[id]=\'+[id]);
52 }
53 ';
54 
55  var $jsmaincall = 'submit_withpar([height],[width],\'[name]\',\'[id]\',\'[url]\')';
56 
57  var $mainform = '
58 <form name="[name]" method="POST" action="[url]">
59 [BLOCK PAR]
60  <input type="hidden" name="[name]" value="[val]"> [ENDBLOCK PAR]
61 </form>
62 ';
63 
64  var $subjs = '
65 function sendform() {
66  var p = self.opener.document.forms.[name];
67  var lf = self.document.[name];
68 [BLOCK PAR]
69  if( lf.[name] ) { p.[name].value = lf.[name].value; } [ENDBLOCK PAR]
70 
71 [BLOCK SEL]
72  if( lf.[name] ) { p.[name].value = lf.[name].options[lf.[name].selectedIndex].value; } [ENDBLOCK SEL]
73  p.submit();
74 }';
75 
76  var $param = array(); // contains all exchanged vars in the form
77  // "key" => "val" , val is the initial value
78  // of the key.
79  function SubForm($name, $width = 100, $height = 100, $mainurl = "", $suburl = "")
80  {
81  $this->name = $name;
82  $this->width = $width;
83  $this->height = $height;
84  $this->mainurl = $mainurl;
85  $this->suburl = $suburl;
86  }
87 
88  function SetParams($array)
89  {
90  $this->param = array_merge($array, $this->param);
91  }
92 
93  function SetParam($key, $val = "", $type = "")
94  {
95  $this->param[$key]["val"] = $val;
96  $this->param[$key]["typ"] = $type;
97  }
98 
99  function SetKey($key)
100  {
101  $this->key = $key;
102  }
103 
104  function GetMainForm()
105  {
106  $lay = new Layout("", null, $this->mainform);
107  $tab = array();
108  reset($this->param);
109  $c = - 1;
110  while (list($k, $v) = each($this->param)) {
111  $tab[$c]["name"] = $k;
112  $tab[$c]["val"] = $v["val"];
113  $c++;
114  }
115  $lay->SetBlockData("PAR", $tab);
116  $lay->Set("url", $this->mainurl);
117  $lay->Set("name", $this->name);
118  return ($lay->gen());
119  }
120 
121  function GetMainJs()
122  {
123  $lay = new Layout("", null, $this->mainjs);
124  $lay->Set("formname", $this->name);
125  $lay->Set("id", $this->key);
126  return ($lay->gen());
127  }
128 
129  function GetSubJs()
130  {
131  $lay = new Layout("", null, $this->subjs);
132  $tab = array();
133  reset($this->param);
134  $isel = $c = - 1;
135  while (list($k, $v) = each($this->param)) {
136  if ($v["typ"] == "sel") {
137  $isel++;
138  $tabsel[$isel]["name"] = $k;
139  } else {
140  $c++;
141  $tab[$c]["name"] = $k;
142  }
143  }
144  if ($isel > - 1) {
145  $lay->SetBlockData("SEL", $tabsel);
146  } else {
147  $lay->SetBlockData("SEL", NULL);
148  }
149  if ($c > - 1) {
150  $lay->SetBlockData("PAR", $tab);
151  } else {
152  $lay->SetBlockData("PAR", NULL);
153  }
154  $lay->Set("name", $this->name);
155  return ($lay->gen());
156  }
157 
158  function GetLinkJsMainCall()
159  {
160  $lay = new Layout("", "", $this->jsmaincall);
161  $lay->Set("url", $this->suburl);
162  $lay->Set("width", $this->width);
163  $lay->Set("height", $this->height);
164  $lay->Set("name", $this->name);
165  return ($lay->gen());
166  }
167 
169  {
170  $lay = new Layout("", "", $this->jsmaincall);
171  $lay->Set("id", "");
172  $lay->Set("url", $this->suburl);
173  $lay->Set("width", $this->width);
174  $lay->Set("height", $this->height);
175  $lay->Set("name", $this->name);
176  return ($lay->gen());
177  }
178  // CLASS END
179 
180 }
181 ?>
← centre documentaire © anakeen - published under CC License - Dynacase