new customfield types to select entry of other apps, eg. a contact

This commit is contained in:
Ralf Becker 2006-10-04 17:10:05 +00:00
parent 88d5a016e0
commit 532264b3fa

View File

@ -48,19 +48,6 @@
{ {
$readonly = $cell['readonly'] || $readonlys[$name]; $readonly = $cell['readonly'] || $readonlys[$name];
// infolog compability
if ($this->appname == 'infolog')
{
$type2 = $value['###typ###'];
$type2_var = 'typ';
unset($value['###typ###']);
$this->customfields = $value;
}
else
{
$type2 = $value;
$type2_var = 'type2';
}
if(!is_array($this->customfields)) if(!is_array($this->customfields))
{ {
$cell['type'] = 'label'; $cell['type'] = 'label';
@ -73,23 +60,15 @@
//echo '<pre style="text-align: left;">'; print_r($value); echo "</pre>\n"; //echo '<pre style="text-align: left;">'; print_r($value); echo "</pre>\n";
foreach($this->customfields as $name => $field) foreach($this->customfields as $name => $field)
{ {
if (!empty($field[$type2_var]) && $field[$type2_var] != $type2) if (!empty($field['type2']) && $field['type2'] != $value)
{ {
continue; // not for our content type continue; // not for our content type
} }
if(empty($field['type']))
{
if (count($field['values'])) $field['type'] = 'select'; // selectbox
elseif ($field['rows'] > 1) $field['type'] = 'textarea'; // textarea
elseif (intval($field['len']) > 0) $field['type'] = 'text'; // regular input field
else $field['type'] = 'label'; // header-row
}
$row_class = 'row'; $row_class = 'row';
$label = &$tpl->new_cell(++$n,'label',$field['label'],'',array( $label = &$tpl->new_cell(++$n,'label',$field['label'],'',array(
'no_lang' => substr(lang($field['label']),-1) == '*' ? 2 : 0 'no_lang' => substr(lang($field['label']),-1) == '*' ? 2 : 0
)); ));
switch ($field['type']) switch ((string)$field['type'])
{ {
case 'select' : case 'select' :
if($this->advanced_search) $field['values'][''] = lang('doesn\'t matter'); if($this->advanced_search) $field['values'][''] = lang('doesn\'t matter');
@ -140,7 +119,7 @@
break; break;
case 'text' : case 'text' :
case 'textarea' : case 'textarea' :
default : case '' : // not set
$field['len'] = $field['len'] ? $field['len'] : 20; $field['len'] = $field['len'] ? $field['len'] : 20;
if($field['rows'] <= 1) if($field['rows'] <= 1)
{ {
@ -153,9 +132,14 @@
{ {
$input = &$tpl->new_cell($n,'textarea','',$this->prefix.$name,array( $input = &$tpl->new_cell($n,'textarea','',$this->prefix.$name,array(
'size' => $field['rows'].($field['len'] > 0 ? ','.(int)$field['len'] : '') 'size' => $field['rows'].($field['len'] > 0 ? ','.(int)$field['len'] : '')
)); ));
} }
break; break;
case 'link-entry':
default : // link-entry to given app
$input = &$tpl->new_cell($n,'link-entry','',$this->prefix.$name,array(
'size' => $field['type'] == 'link-entry' ? '' : $field['type'],
));
} }
if ($readonly) $input['readonly'] = true; if ($readonly) $input['readonly'] = true;