Core  3.2
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  * @package FDL
5 */
6 /**
7  * Generated Header (not documented yet)
8  *
9  * @author Anakeen
10  * @version $Id: Class.SubForm.php,v 1.3 2006/06/20 16:18:07 eric Exp $
11  * @package FDL
12  * @subpackage CORE
13  */
14 /**
15  */
16 // ---------------------------------------------------------------------------
17 // $Id: Class.SubForm.php,v 1.3 2006/06/20 16:18:07 eric Exp $
18 // $Source: /home/cvsroot/anakeen/freedom/core/Class/Form/Class.SubForm.php,v $
19 // ---------------------------------------------------------------
20 // $Log: Class.SubForm.php,v $
21 //
22 //
23 class SubForm
24 {
25  // This class is used to produce HTML/JS code when you want to
26  // create a separate window which exchange values with its parent
27  // window (for instance an edit/update window or a query window)
28  var $mainjs = '
29 function submit_withpar(height,width,name,[id],url) {
30  subwindow(height,width,name,url+\'&[id]=\'+[id]);
31 }
32 ';
33 
34  var $jsmaincall = 'submit_withpar([height],[width],\'[name]\',\'[id]\',\'[url]\')';
35 
36  var $mainform = '
37 <form name="[name]" method="POST" action="[url]">
38 [BLOCK PAR]
39  <input type="hidden" name="[name]" value="[val]"> [ENDBLOCK PAR]
40 </form>
41 ';
42 
43  var $subjs = '
44 function sendform() {
45  var p = self.opener.document.forms.[name];
46  var lf = self.document.[name];
47 [BLOCK PAR]
48  if( lf.[name] ) { p.[name].value = lf.[name].value; } [ENDBLOCK PAR]
49 
50 [BLOCK SEL]
51  if( lf.[name] ) { p.[name].value = lf.[name].options[lf.[name].selectedIndex].value; } [ENDBLOCK SEL]
52  p.submit();
53 }';
54 
55  var $param = array(); // contains all exchanged vars in the form
56  // "key" => "val" , val is the initial value
57  // of the key.
58  function __construct($name, $width = 100, $height = 100, $mainurl = "", $suburl = "")
59  {
60  $this->name = $name;
61  $this->width = $width;
62  $this->height = $height;
63  $this->mainurl = $mainurl;
64  $this->suburl = $suburl;
65  }
66 
67  function SetParams($array)
68  {
69  $this->param = array_merge($array, $this->param);
70  }
71 
72  function SetParam($key, $val = "", $type = "")
73  {
74  $this->param[$key]["val"] = $val;
75  $this->param[$key]["typ"] = $type;
76  }
77 
78  function SetKey($key)
79  {
80  $this->key = $key;
81  }
82 
83  function GetMainForm()
84  {
85  $lay = new Layout("", null, $this->mainform);
86  $tab = array();
87  reset($this->param);
88  $c = - 1;
89  foreach ($this->param as $k => $v) {
90  $tab[$c]["name"] = $k;
91  $tab[$c]["val"] = $v["val"];
92  $c++;
93  }
94  $lay->SetBlockData("PAR", $tab);
95  $lay->Set("url", $this->mainurl);
96  $lay->Set("name", $this->name);
97  return ($lay->gen());
98  }
99 
100  function GetMainJs()
101  {
102  $lay = new Layout("", null, $this->mainjs);
103  $lay->Set("formname", $this->name);
104  $lay->Set("id", $this->key);
105  return ($lay->gen());
106  }
107 
108  function GetSubJs()
109  {
110  $lay = new Layout("", null, $this->subjs);
111  $tab = array();
112  reset($this->param);
113  $isel = $c = - 1;
114  foreach ($this->param as $k => $v) {
115  if ($v["typ"] == "sel") {
116  $isel++;
117  $tabsel[$isel]["name"] = $k;
118  } else {
119  $c++;
120  $tab[$c]["name"] = $k;
121  }
122  }
123  if ($isel > - 1) {
124  $lay->SetBlockData("SEL", $tabsel);
125  } else {
126  $lay->SetBlockData("SEL", NULL);
127  }
128  if ($c > - 1) {
129  $lay->SetBlockData("PAR", $tab);
130  } else {
131  $lay->SetBlockData("PAR", NULL);
132  }
133  $lay->Set("name", $this->name);
134  return ($lay->gen());
135  }
136 
137  function GetLinkJsMainCall()
138  {
139  $lay = new Layout("", "", $this->jsmaincall);
140  $lay->Set("url", $this->suburl);
141  $lay->Set("width", $this->width);
142  $lay->Set("height", $this->height);
143  $lay->Set("name", $this->name);
144  return ($lay->gen());
145  }
146 
148  {
149  $lay = new Layout("", "", $this->jsmaincall);
150  $lay->Set("id", "");
151  $lay->Set("url", $this->suburl);
152  $lay->Set("width", $this->width);
153  $lay->Set("height", $this->height);
154  $lay->Set("name", $this->name);
155  return ($lay->gen());
156  }
157  // CLASS END
158 
159 }
160 ?>
Layout is a template generator.
SetKey($key)
print $fam getTitle() $fam name
__construct($name, $width=100, $height=100, $mainurl="", $suburl="")
GetLinkJsMainCall()
SetParams($array)
SetParam($key, $val="", $type="")
GetEmptyJsMainCall()
← centre documentaire © anakeen