21 return $this->
add($prm[
'type'], $prm, $isI18n);
31 'dbList'=>$related[
'fk2'][
'link'],
32 'name'=>$related[
'name'],
33 'label'=>$related[
'label'],
34 'valid'=>array_key_exists(
'valid', $related)? $related[
'valid'] :
false 36 if (isset($related[
'comment']) && is_array($related[
'comment']))
37 $prm = array_merge($prm, $related[
'comment']);
38 $prm[
'dbList'][
'fields'] = $related[
'fk2'][
'link'][
'ident'].
39 ($prm[
'dbList'][
'fields']?
','.$prm[
'dbList'][
'fields'] : null);
41 if (isset($related[
'fields']) && count($related[
'fields'])) {
42 $type =
'checkbox_fields';
43 $prm[
'table'] = $related[
'tableObj'];
44 $prm[
'fields'] = $related[
'fields'];
46 if (count($prm[
'dbList'][
'fields'])) {
48 foreach(explode(
',', $prm[
'dbList'][
'fields']) as
$f) {
49 if ($f != $prm[
'dbList'][
'ident']) {
54 $prm[
'dbList'][
'order'] = implode(
' ASC, ', $tmp).
' ASC';
56 if (array_key_exists(
'formType', $related) && $related[
'formType'])
57 $type = $related[
'formType'];
58 return $this->
add($type, $prm);
68 $saveAutoValidRule = $this->cfg->autoValidRule;
69 $this->cfg->autoValidRule = array();
70 if (isset($field[
'formTypeFilter'])) {
71 $field[
'formType'] = $field[
'formTypeFilter'];
72 }
else if (isset($field[
'formType'])) {
73 unset($field[
'formType']);
76 $this->cfg->autoValidRule = $saveAutoValidRule;
78 switch($prm[
'type']) {
81 $prm[
'type'] =
'text';
85 $prm[
'type'] =
'range_date';
88 if ($field[
'type'] ==
'tinyint')
89 $prm[
'list'] += array(
'-1'=>$this->cfg->all);
91 $prm[
'type'] =
'checkbox';
92 $prm[
'valueNone'] = -1;
96 $prm[
'list'] += array(
'-1'=>$this->cfg->all);
97 if (isset($prm[
'list'][0]))
98 unset($prm[
'list'][0]);
99 $prm[
'valueNone'] = -1;
103 $prm[
'type'] =
'checkbox';
104 $prm[
'list'] = array(
'1'=>$this->cfg->getInArray(
'listBool', 1));
105 $prm[
'uniqValue'] =
true;
108 $prm[
'type'] =
'range_numeric';
109 $prm[
'valid'][
'validEltArray'] =
true;
110 $prm[
'allowedRange'] = $this->cfg->table->getRange($prm[
'name']);
113 $prm[
'valid'][
'required'] =
false;
114 $prm[
'valid'][
'dbUnique'] =
false;
115 return $this->
add($prm[
'type'], $prm);
125 'dbList'=>$related[
'fk2'][
'link'],
126 'name'=>$related[
'name'],
127 'label'=>$related[
'label'],
128 'valid'=>array_key_exists(
'valid', $related)? $related[
'valid'] :
false 130 $prm[
'dbList'][
'fields'] = $related[
'fk2'][
'link'][
'ident'].
131 ($prm[
'dbList'][
'fields']?
','.$prm[
'dbList'][
'fields'] : null);
133 if (count($prm[
'dbList'][
'fields'])) {
135 foreach(explode(
',', $prm[
'dbList'][
'fields']) as
$f) {
136 if ($f != $prm[
'dbList'][
'ident']) {
141 $prm[
'dbList'][
'order'] = implode(
' ASC, ', $tmp).
' ASC';
143 if (array_key_exists(
'formTypeFilter', $related) && $related[
'formTypeFilter'])
144 $type = $related[
'formTypeFilter'];
145 return $this->
add($type, $prm);
156 $prm = array_merge(array(
157 'name'=>$field[
'name'],
158 'label'=>$field[
'label'],
159 'value'=>array_key_exists(
'value', $field)? $field[
'value'] : $field[
'default'],
160 'link'=>array_key_exists(
'link', $field)? $field[
'link'] : null,
161 'valid'=>array(
'required'=>$field[
'required'])
162 ), $field[
'comment']);
164 if ($field[
'unique'] && ! array_key_exists(
'dbUnique', $prm[
'valid'])) {
165 $prm[
'valid'][
'dbUnique'] = array(
166 'table'=>$this->cfg->table,
167 'field'=>$field[
'name'],
168 'value'=>$prm[
'value']
171 if (array_search($field[
'name'], $this->cfg->autoValidRule) !==
false && !array_key_exists($field[
'name'], $prm[
'valid']))
172 $prm[
'valid'][$field[
'name']] =
true;
174 if (array_search(
'hidden', $field[
'comment'],
true) !==
false)
175 $ret = array_merge($prm, array(
'type'=>
'hidden'));
177 if (!empty($field[
'link'])) {
180 $prm[
'list'] = $field[
'link'][
'list'];
181 $prm[
'valueNone'] = 0;
185 if ($field[
'link'][
'fields']) {
186 $linkedTable =
db::get(
'table', $field[
'link'][
'table'], array(
187 'db'=>$this->cfg->table->getDb()
190 foreach(explode(
',', $field[
'link'][
'fields']) as $t) {
191 if ($linkedInfo = $linkedTable->getLinkedTableName($t)) {
192 $alias = $field[
'name'].
'_'.$linkedInfo[
'table'];
194 'table'=>$linkedInfo[
'table'],
197 'on'=>$field[
'link'][
'table'].
'.'.$linkedInfo[
'field'].
'='.$alias.
'.'.$linkedInfo[
'ident']
200 foreach(explode(
',', $linkedInfo[
'fields']) as $tt) {
201 $ttmp[] = $alias.
'.'.$tt;
202 $ttmp[] =
'"'.$linkedInfo[
'sep'].
'"';
205 $tmp[] =
'CONCAT('.implode(
',', $ttmp).
')';
207 $tmp[] = $field[
'link'][
'table'].
'.'.$t;
209 $fields.=
','.implode(
',', $tmp);
210 $order = implode(
' ASC, ', $tmp).
' ASC';
212 $prm[
'dbList'] = array(
213 'fields'=>$field[
'link'][
'table'].
'.'.$field[
'link'][
'ident'].$fields,
214 'i18nFields'=>$field[
'link'][
'i18nFields'],
215 'ident'=>$field[
'link'][
'ident'],
216 'table'=>$field[
'link'][
'table'],
218 'sep'=>$field[
'link'][
'sep'],
219 'where'=>$field[
'link'][
'where'],
220 'order'=>isset($field[
'link'][
'order']) ? $field[
'link'][
'order'] : $order,
221 'sepGr'=>$field[
'link'][
'sepGr'],
222 'nbFieldGr'=>$field[
'link'][
'nbFieldGr']
224 $ret = array_merge($prm, array(
'type'=>$type));
226 switch($field[
'type']) {
230 $prm[
'list'] = $field[
'precision'];
231 $prm[
'needOut'] =
true;
235 $prm[
'valid'][
'different'] =
'0000-00-00';
240 $prm[
'valid'][
'different'] =
'0000-00-00 00:00:00';
250 $key = array_search(
'richtext', $field[
'comment']);
251 if ($key !==
false) {
253 unset($field[
'comment'][$key]);
254 $prm[
'html'] = $field[
'comment'];
255 if (array_key_exists(
'html', $prm[
'html'])) {
256 $prm[
'html'] = array_merge_recursive($prm[
'html'], $prm[
'html'][
'html']);
257 unset($prm[
'html'][
'html']);
259 if (array_key_exists(
'tinyMce', $field))
260 $prm[
'tinyMce'] = $field[
'tinyMce'];
261 unset($prm[
'html'][
'tinyMce']);
264 $prm[
'maxlength'] = $field[
'length'];
271 $prm[
'list'] = isset($field[
'precision']) ? $field[
'precision'] : $this->cfg->listBool;
272 $prm[
'inline'] =
true;
273 if ($field[
'type'] !=
'tinyint' || ($field[
'type'] ==
'tinyint' && $field[
'length'] == 1)) {
274 $prm[
'valid'][
'required'] =
false;
283 $prm[
'maxlength'] = $field[
'length'];
284 $prm[
'valid'][
'int'] =
true;
294 $prm[
'maxlength'] = $field[
'precision']? $field[
'length']+1 : $field[
'length'];
295 $prm[
'valid'][
'numeric'] =
true;
299 if (count($field[
'comment']) == 1 && array_key_exists(0, $field[
'comment']))
300 $prm[
'helper'] = $field[
'comment'][0];
302 $prm = array_merge($prm, $field[
'comment']);
305 $type = array_key_exists(0, $field[
'comment']) && !empty($field[
'comment'][0])? $field[
'comment'][0] :
'text';
306 $prm[
'maxlength'] = $field[
'length'];
309 $ret = array_merge($prm, array(
'type'=>$type));
312 if (array_key_exists(
'formType', $field) && $field[
'formType'])
313 $ret[
'type'] = $field[
'formType'];
static get($type, $table, array $prm=array())